package com.jiuyi.controller;

import com.jiuyi.common.R;
import com.jiuyi.dto.StatusIdDto;
import com.jiuyi.entity.Orders;
import com.jiuyi.service.Impl.OrdersServiceImpl;
import com.jiuyi.service.OrdersService;
import com.jiuyi.vo.OrdersVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.time.LocalDateTime;
import java.util.Map;

/**
 * DATA: 2022/10/24
 * Author: 晨夕
 */
@Slf4j
@RestController
@RequestMapping("/order")
public class OrdersController {

    @Autowired
    private OrdersServiceImpl ordersServiceImpl;

    /**
     * 去支付
     */
    @PostMapping("/submit")
    public R submit(@RequestBody Orders orders, HttpServletRequest request){
        return ordersServiceImpl.submit(orders,request);
    }
    /**
     * 查看历史订单
     */
    @GetMapping("/userPage")
    public R selectPage(int page,int pageSize){
        return ordersServiceImpl.selectPage(page,pageSize);
    }
    /**
     * 后台订单明细
     */
    @GetMapping("/page")
    public R<OrdersVo> selectByPage(int page, int pageSize, String number, LocalDateTime orderTime, LocalDateTime checkoutTime){
        return ordersServiceImpl.selectByPages(page, pageSize, number, orderTime, checkoutTime);
    }
    /**
     * 修改派送状态
     */
    @PutMapping
    public R updatePayMethod(@RequestBody StatusIdDto statusIdDto){
        return ordersServiceImpl.updatePayMethod(statusIdDto);
    }
}
